import useUserStore from "@/store/modules/user";
import Cookies from "js-cookie";

export default {
  mounted(el, binding, vnode) {
    const { value } = binding;
    const super_admin = "admin";
    const roleKey = Cookies.get("role-key");

    if (value && value instanceof Array && value.length > 0) {
      const roleFlag = value;

      // const equalRole = roleKey === super_admin || roleFlag.includes(roleKey);
      const equalRole = roleFlag.includes(roleKey);

      if (!equalRole) {
        el.parentNode && el.parentNode.removeChild(el);
      }
    } else {
      throw new Error(`请设置角色权限标签值`);
    }
  },
};
